<!--
 * @Author: yuqy
 * @Date: 2023-04-10 19:26:39
 * @LastEditors: yuqy
 * @LastEditTime: 2023-10-23 13:19:57
 * @Descripttion: -
-->

<template>
  <div class="menu_wrap">
    <div class="menu_item" v-ripple>
      <img src="@/assets/img/login/menu.png" alt>
      <p v-if="VUE_APP_TYPE=='ODIN'">双师</p>
      <p v-if="VUE_APP_TYPE=='MID'">互动</p>
      <div class="menu_bg" @click.stop="goHome($event)"></div>
    </div>
    <div class="menu_item" v-ripple>
      <img src="@/assets/img/login/exit.png" alt>
      <p>退出</p>
      <div class="menu_bg" @click.stop="exit($event)"></div>
    </div>
    <div class="menu_item menu_item_logo" style="-webkit-app-region: drag;" v-ripple>
      <img src="@/assets/img/login/logo.jpg" alt>
      <div class="menu_bg"></div>
    </div>
  </div>
</template>
<script >
// 用于页面间通信，获取实时页面状态
const userMsgBc = new BroadcastChannel('getUserMainMsg');
export default {
  setup() {},
  data() {
    return {};
  },
  created() {
    // 接收其他页面，发送的信息
    userMsgBc.onmessage = () => {
      let { type, name } = res.data;
      // 获取其他页面，传递过来的参数 某个页面最小化
      if (type == "isMini") {
        window.electronAPI.menuclick("mini", {
          pageName: name,
          isMini: true
        });
      }
    };
  },
  unmounted() {
    userMsgBc.onmessage = null;
  },
  methods: {
    exit() {
      if (this.APP_IS_Web) return;
      window.electronAPI.menuclick("winQuit");
    },
    goHome() {
      if (this.APP_IS_Web) return this.$router.push("./home");
      // 打开electorn 主页面
      window.electronAPI.menuclick("menu", { type: "menu" });
    }
  }
};
</script>
<style scoped lang='less'>
.menu_wrap {
  width: 100%;
  height: 100%;
  max-height: 300px;
  max-width: 60px;
  max-width: auto;
  margin: auto;
  font-size: 0;
  border-radius: 6px;
  overflow: hidden;
  background: #413638;
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  .menu_item {
    padding: 0px 12px 0px;
    position: relative;
    &:nth-child(1) {
      padding-top: 10px;
    }
    .menu_bg {
      position: absolute;
      width: 100%;
      height: 100%;
      top: 0;
      left: 0;
      z-index: 99;
      background: transparent;
    }
    p {
      font-size: 13px;
      color: #fff;
      text-align: center;
      padding: 2px 0;
      white-space: nowrap;
      margin: 0;
    }
  }
  img {
    width: 100%;
    margin: auto;
    display: block;
  }
  .menu_item_logo {
    border-top: 1px solid #fff;
    padding: 10px 0px 10px;
    margin: 0px 8px 0;
    img {
      width: 100%;
      border-radius: 100%;
    }
  }
}
</style>
